package com.taoxi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.taoxi.common.annotation.Log;
import com.taoxi.common.core.controller.BaseController;
import com.taoxi.common.core.domain.AjaxResult;
import com.taoxi.common.enums.BusinessType;
import com.taoxi.system.domain.Dispute;
import com.taoxi.system.service.IDisputeService;
import com.taoxi.common.utils.poi.ExcelUtil;
import com.taoxi.common.core.page.TableDataInfo;

/**
 * 纠纷管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-10
 */
@RestController
@RequestMapping("/system/dispute")
public class DisputeController extends BaseController
{
    @Autowired
    private IDisputeService disputeService;

    /**
     * 查询纠纷管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispute:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dispute dispute)
    {
        startPage();
        List<Dispute> list = disputeService.selectDisputeList(dispute);
        return getDataTable(list);
    }

    /**
     * 导出纠纷管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispute:export')")
    @Log(title = "纠纷管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dispute dispute)
    {
        List<Dispute> list = disputeService.selectDisputeList(dispute);
        ExcelUtil<Dispute> util = new ExcelUtil<Dispute>(Dispute.class);
        util.exportExcel(response, list, "纠纷管理数据");
    }

    /**
     * 获取纠纷管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispute:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(disputeService.selectDisputeById(id));
    }

    /**
     * 新增纠纷管理
     */
    @PreAuthorize("@ss.hasPermi('system:dispute:add')")
    @Log(title = "纠纷管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dispute dispute)
    {
        return toAjax(disputeService.insertDispute(dispute));
    }

    /**
     * 修改纠纷管理
     */
    @PreAuthorize("@ss.hasPermi('system:dispute:edit')")
    @Log(title = "纠纷管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dispute dispute)
    {
        return toAjax(disputeService.updateDispute(dispute));
    }

    /**
     * 删除纠纷管理
     */
    @PreAuthorize("@ss.hasPermi('system:dispute:remove')")
    @Log(title = "纠纷管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(disputeService.deleteDisputeByIds(ids));
    }
}
